{extend name="base"/}
{block name="title"}
    全部订单
{/block}
{block name="css"}
<link rel="stylesheet" href="__MOBILE__/css/zhang.css">
{/block}
{block name="content"}
<div class="head">
    <div class="head_left"><a href="javascript:history.go(-1)"><img src="__MOBILE__/images/true.png" alt=""></a></div>
    <div class="head_con">我的订单</div>
    <div class="head_right"></div>
</div>
{if $order !== ''}
{foreach $order as $k=>$value}


<div class="suss">
    {foreach $value as $key=>$orders}
    <div class="suss_tit">
        <img src="__MOBILE__/images/dianpuimg.png" alt=""><p>{$key}</p><p>{if $status ==1 }已付款 {elseif $status == 2 /} 已发货{else /}已完成 {/if}</p>
    </div>
    {foreach $orders as $shop}
    <ul class="shop_list">
        <li>
            <div class="shop_list_left"><img src="{$shop['img1']}" alt=""></div>
            <div class="shop_list_right">
                <div>{$shop['name']}</div>
                <div><p>金额:</p><p class="jiage">￥ <span>{$shop['wallet_num']}</span> +<span>{$shop['integral_num']}</span></p></div>
                <div><p>数量:</p><p class="num">X <span>{$shop['num']}</span></p></div>
            </div>
        </li>
    </ul>
    <div class="shop_foot"> 
        {if $status ==2 }<div class="shop_foot_left">确认收货<input type="hidden" value="{$shop['order_id']}"></div>{/if}
        <div class="shop_foot_right">合计: <span>0</span></div>
    </div>
</div>
{/foreach}
{/foreach}
{/foreach}
{/if}
{/block}
{block name="js"}
<script type="text/javascript">
    $(".shop_foot_left").click(function(){
        var num = $(this).children().val();
        //msg_alert("收获成功");
        //$(this).html("已收货");
        $.ajax({
           url: '/langjinmobile/card/delivery',
           type: 'POST',
           data:{'num':num},
           datatype:'json',
           success: function(res) {
              console.log(res);
              if(res.code==1){
                //刷新页面
                msg_alert(res.msg);
                $(".popup").hide();
                window.location.reload();

              }else{
                msg_alert(res.msg);
              }
           }
        });
    });


    var $elements = $('.suss');
    var len = $elements.length;
    for(var i = 0; i < len; i++){
        var shopnum = Number($(".suss").eq(i).find(".num").children("span").html());
        if($(".suss").eq(i).children(".shop_list").find("li").length == 1){
            $(".shop_foot_right span").eq(i).html(Number($(".suss").eq(i).find(".jiage").children("span").eq(0).html()) * shopnum +' + '+ Number($(".suss").eq(i).find(".jiage").children("span").eq(1).html()) * shopnum);
        }
        // *******以下注释误删
        // else{
        //     var att = 0;
        //     var lens = $(".suss").eq(i).find("li").length;
        //     for(var j = 0; j < lens; j++){
        //         att += Number($(".suss").eq(i).find(".jiage").children("span").eq(j).html()) * Number($(".suss").eq(i).find(".num").children("span").eq(j).html());
        //         $(".shop_foot_right span").eq(i).html(att);
        //     }
        // }
    }

</script>
{/block}